﻿#region Using Directives

    using System;
    using System.Xml.Linq;

    using Csla;

    using MarketPulse.BusinessLogic.Core;
    using MarketPulse.BusinessLogic.Common.Criteria;

#endregion

namespace MarketPulse.BusinessLogic.Common
{
    /// <summary>
    /// This class represents a read only instance of an EnquiryType within the system.
    /// </summary>
    [Serializable]
    [Csla.Server.ObjectFactory("MarketPulse.DataAccess.Factory.EnquiryFactory, MarketPulse.DataAccess.Factory", "FetchTypeInfo")]
    public class EnquiryTypeInfo : MarketPulseReadOnlyBase<EnquiryTypeInfo>
    {

        #region Constructors

            /// <summary>
            /// Default constructor is private in order to (try to) enforce construction
            /// only via the static factory methods provided.
            /// </summary>
            private EnquiryTypeInfo()
            {
            }

        #endregion

        #region Methods

            #region Factory Methods

                /// <summary>
                /// Method used to retrieve a EnquiryTypeInfo object 
                /// </summary>
                /// <param name="enquiryTypeGuid">The guid of the Branch info object to retrieve</param>
                /// <returns>The populated Branch info object survey</returns>
                public static EnquiryTypeInfo GetByGuid(Guid enquiryTypeGuid)
                {
                    return DataPortal.Fetch<EnquiryTypeInfo>(new SingleCriteria<Guid>(enquiryTypeGuid));
                }

            #endregion

        #endregion

        #region Properties

            #region Association GUID Properties (Foreign Keys)

                ///// <summary>
                ///// The GUID of the company (BusinessObject) that this Branch belongs to 
                ///// </summary>
                //public static PropertyInfo<Nullable<Guid>> mCompanyGUIDProperty = RegisterProperty<Nullable<Guid>>(p => p.CompanyGUID);
                ///// <summary>
                ///// The GUID of the company (BusinessObject) that this Branch belongs to 
                ///// </summary>
                //public Nullable<Guid> CompanyGUID
                //{
                //    get { return GetProperty(mCompanyGUIDProperty); }
                //}

            #endregion

            /// <summary>
            /// A human readable name for this Branch
            /// </summary>
            public static PropertyInfo<XElement> mLabelProperty = RegisterProperty<XElement>(p => p.Label);
            /// <summary>
            /// A human readable name for this Branch
            /// </summary>
            public XElement Label
            {
                get { return GetProperty(mLabelProperty); }
            }

            #region Association Properties (Related Objects)

                ///// <summary>
                ///// The list of (Read Only) EnquiryReasons associated with this EnquiryType
                ///// </summary>
                //public static PropertyInfo<EnquiryReasonInfoList> EnquiryReasonInfoListProperty = RegisterProperty<EnquiryReasonInfoList>(p => p.EnquiryReasonInfoList);
                ///// <summary>
                ///// The list of (Read Only) EnquiryReasons associated with this EnquiryType
                ///// </summary>
                //public EnquiryReasonInfoList EnquiryReasonInfoList
                //{
                //    get
                //    {
                //        if (!FieldManager.FieldExists(EnquiryReasonInfoListProperty))
                //        {
                //            LoadProperty(EnquiryReasonInfoListProperty, EnquiryReasonInfoList.GetByEnquiryTypeGUID(this.GUID.Value));
                //            OnPropertyChanged(EnquiryReasonInfoListProperty);
                //        }
                //        return ReadProperty(EnquiryReasonInfoListProperty);
                //    }
                //}

            #endregion

        #endregion       
    }
}
